package org.ala.tiktools.mybatis.interceptor;

/**
 * 拦截器执行结果
 *
 * @author ala
 * @date 2025-02-24 13:00
 */
public class InterceptResult {
    /**
     *  执行结果
     */
    protected Object res;
    /**
     *  是否使用res的结果直接返回
     *  <p> 需要与拦截器的加载顺序联合使用
     *  <p> 当为true时，该拦截器的结果将作为方法结果直接返回
     */
    protected boolean returnRes;

    public static InterceptResult build(Object res, boolean returnRes) {
        InterceptResult r = new InterceptResult();
        r.res = res;
        r.returnRes = returnRes;
        return r;
    }

    public static InterceptResult next() {return build(null, false);}

    public Object getRes() {
        return res;
    }

    public void setRes(Object res) {
        this.res = res;
    }

    public InterceptResult res(Object res) {
        setRes(res);
        return this;
    }

    public boolean isReturnRes() {
        return returnRes;
    }

    public void setReturnRes(boolean returnRes) {
        this.returnRes = returnRes;
    }

    public InterceptResult returnRes(boolean returnRes) {
        setReturnRes(returnRes);
        return this;
    }
}
